package com.springboot.sharding;


import java.util.Collection;

import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;

public final class PreciseShardingAlgorithmImpl implements PreciseShardingAlgorithm<Integer> {

	public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Integer> shardingValue) {
		for (String each : availableTargetNames) {
            if (shardingValue.getValue() == 101) {
                return "ds_0";
            }else if(shardingValue.getValue() == 102){
            	 return "ds_1";
            }
        }
		return "ds_0";
	}
    
}